#include "StdAfx.h"
#include "CTPQuote.h"
#include <stdio.h>
#include "Quote.h"

void CCTPQuote::OnFrontConnected()
{
	QUOTE_INSTANCE->OnFrontConnected();
}

void CCTPQuote::OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
	int eId = -1;
	if (pRspInfo)
	{
		eId = pRspInfo->ErrorID;
	}

	if (eId == 0)
	{
		sprintf(QUOTE_INSTANCE->GetTradingDay(),"%s",QUOTE_INSTANCE->GetApi()->GetTradingDay());
	}
	else
	{
		OnRspError(pRspInfo,nRequestID,bIsLast);
	}
	

	QUOTE_INSTANCE->OnRspUserLogin(eId);
	
}

void CCTPQuote::OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
	QUOTE_INSTANCE->OnRtnError(pRspInfo->ErrorID, pRspInfo->ErrorMsg);
}

void CCTPQuote::OnFrontDisconnected(int nReason)
{
	QUOTE_INSTANCE->OnRspUserLogout(nReason);
}

void CCTPQuote::OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData)
{
	QUOTE_INSTANCE->OnRtnDepthMarketData(pDepthMarketData);
}

